package com.springboot.ball.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.springboot.ball.pojo.ChatMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatMessageMapper extends BaseMapper<ChatMessage> {
    // 添加自定义历史查询
    @Select("SELECT * FROM chat_message " +
            "WHERE (from_user_id = #{from} AND to_user_id = #{to}) " +
            "OR (from_user_id = #{to} AND to_user_id = #{from}) " +
            "ORDER BY create_time ASC")
    List<ChatMessage> selectHistory(@Param("from") Integer from, @Param("to") Integer to);
}
